import type { ContractRow } from '@/api/modules/types/contract'

export const rules = {
  OwnerOrgObjID: [
    { required: true, message: '请选择运维公司', trigger: 'change' },
  ],
  ContractCode: [
    { required: true, message: '请输入合同编号', trigger: 'blur' },
  ],
  ContactPerson: [
    { required: true, message: '请输入联系人', trigger: 'blur' },
  ],
  ContactTel: [
    { required: true, message: '请输入联系电话', trigger: 'blur' },
  ],
  StartTime: [
    { required: true, message: '请选择开始时间', trigger: 'change' },
  ],
  EndTime: [
    { required: true, message: '请选择结束时间', trigger: 'change' },
  ],
  TotalMoney: [
    { required: true, message: '请输入合同总金额', trigger: 'blur' },
  ],
  IncomeMoney: [
    { required: true, message: '请输入收款金额', trigger: 'blur' },
  ],
  IncomeTime: [
    { required: true, message: '请选择收款时间', trigger: 'change' },
  ],
  InvoiceMoney: [
    { required: true, message: '请输入开票金额', trigger: 'blur' },
  ],
  InvoiceTime: [
    { required: true, message: '请选择开票时间', trigger: 'change' },
  ],
  Remark: [
    { required: true, message: '请输入备注', trigger: 'blur' },
  ],

}

export function useContractForm(): { formData: Ref<ContractRow>, initForm: () => void } {
  function getData(): ContractRow {
    return {
      ContactPerson: '',
      ContactTel: '',
      ContractCode: '',
      EndTime: '',
      IncomeMoney: 0,
      IncomeTime: '',
      InvoiceMoney: 0,
      InvoiceTime: '',
      ObjID: '',
      OwnerOrgName: '',
      OwnerOrgObjID: '',
      Remark: '',
      StartTime: '',
      TotalMoney: 0,
    }
  }
  const formData = ref<ContractRow>(getData())
  const initForm = () => {
    formData.value = getData()
  }

  return { formData, initForm }
}
